#ifndef DISTRIBUTION_H
#define DISTRIBUTION_H

#include <QVector>
#include <QPointF>
#include <gsl/gsl_randist.h>

class Distribution
{
public:

    static Distribution* sharedInstance();

    ~Distribution();

    double randomUniform(double start = 0, double end = 1);

    double randomNormal(double mean = 0, double sigma = 1);

    double randomGamma(double alpha, double beta);

    double randomBernoulli(double p);

    double likelihoodNormal(double x, double mean = 0, double sigma = 1);

    double likelihoodGamma(double x, double alpha, double beta);

    double likelihoodInverseGamma(double x, double alpha, double beta);

    double likelihoodBernoulli(int x, double p = 0.5);

    double likelihoodBeta(double x, double alpha, double beta);

    double likelihoodPoisson(int x, double rate);

    double mean(QVector<double>& data);

    double variance(QVector<double>& data);

    double minimum(QVector<double>& data);

    double maximum(QVector<double>& data);

    QVector<QPointF> histogramLine(QVector<double>& data, int bucketCount);

    QVector<int> histogram(QVector<double>& data, int bucketCount);

    double gamma(double x);

private:
    Distribution();

    gsl_rng* randomNumberGenerator;

};

#endif // DISTRIBUTION_H
